package com.gitee.wsl.doc.prosemirror.model.node.ext

import com.gitee.wsl.doc.prosemirror.model.fragment.Fragment
import com.gitee.wsl.doc.prosemirror.model.node.Node
import com.gitee.wsl.doc.prosemirror.model.node.NodeType
import com.gitee.wsl.ext.list.forEachReversedWithIndex

fun Node.withWrappers(wrap: List<NodeType>, from: Int = 0): Node {
    var node = this
    wrap.forEachReversedWithIndex { index, e ->
        node = e.create(null, Fragment.Companion.from(node))
    }
    return node
}